﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Specialized;
using System.Threading;
using System.Globalization;

namespace RCREEE.Web
{
    public partial class Topics : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                NameValueCollection attributes = new NameValueCollection();

                object LanguageCode = Session["LanguageCode"];
                object BrowsingMode = 2;
                object IsAdmin = Session["IsAdmin"];

                if (LanguageCode != null)
                {
                    attributes.Add("LanguageCode", LanguageCode.ToString());
                    attributes.Add("connectionStringName", "ConnectionString");
                    attributes.Add("BrowsingMode", BrowsingMode.ToString());

                    ChangeUICulture();

                    SiteMapDataSource1.Provider = new SqlSiteMapProvider();

                    SiteMapDataSource1.Provider.Initialize("SqlSiteMapProvider", attributes);
                }
            }
        }
        private void ChangeUICulture()
        {
            try
            {
                string culture = "en";

                if (Session["LanguageCode"] != null)
                {
                    int LanguageCode = Convert.ToInt32(Session["LanguageCode"]);

                    switch (LanguageCode)
                    {
                        case 1033:
                            culture = "en";
                            break;

                        case 1025:
                            culture = "ar";
                            break;

                        case 1036:
                            culture = "fr";
                            break;

                        default:
                            culture = "en";
                            break;
                    }
                }

                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
            }
            catch { }
        }
    }
}